#include "cuMath.h"

namespace z3d{
	namespace core{

		uint32_t  nextPower2(uint32_t val)
		{
			// important next pow2 of 64 is 64
			if(isPower2(val))
				return val;
			val--;
			val = (val >> 1) | val;
			val = (val >> 2) | val;
			val = (val >> 4) | val;
			val = (val >> 8) | val;
			val = (val >> 16) | val;
			return ++val; // Val is now the next highest power of 2.
		}
		bool isPower2(uint32_t  x)
		{	
			return ( (x > 0) && ((x & (x - 1)) == 0) );
		}
	};
};
